package com.cn.pojo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

@Repository
public class CollectionInjection {
    @Value("${array.values}")
    private String[] array;
    @Value("#{'${list.values}'.split(',')}")
    private List<String> list;
    @Value("#{'${set.values}'.split(',')}")
    private Set<String> set;
    @Value("#{${map.values}}")
    private Map<String,String> map;
    @Value("#{${properties.values}}")
    private Properties properties;
    
    public void printArray(){
        System.out.println("Array:");
        for (String value : array) {
            System.out.println(value);
        }
    }
    
    public void printList(){
        System.out.println("List");
        for (String value : list) {
            System.out.println(value);
        }
    }

    public void printSet(){
        System.out.println("Set");
        for (String value : set) {
            System.out.println(value);
        }
    }

    public void printMap(){
        System.out.println("Map");
        for (Map.Entry<String, String> stringStringEntry : map.entrySet()) {
            System.out.println(stringStringEntry.getKey()+"--"+stringStringEntry.getValue());
        }
    }
    public void printProperties(){
        System.out.println("Properties");
       properties.forEach((key,value)-> System.out.println(key+"--"+value));
    }
    
}
